package com.yellowcong.utils;

import java.util.regex.Pattern;

public class StringUtils {

	public static String removeHtmlNull(String str ){
		return str.replaceAll("&nbsp;", "");
	}
	/**
	 * 清除html中的所有的标签
	 * @param htmlStr
	 * @return
	 */
	public static String removeHtmlTags(String htmlStr){
		String textStr = "";
		String scriptReg = "<[\\s]*?script[^>]*?>[\\s\\S]*?<[\\s]*?\\/[\\s]*?script[\\s]*?>";
		String styleReg = "<[\\s]*?style[^>]*?>[\\s\\S]*?<[\\s]*?\\/[\\s]*?style[\\s]*?>";
		String htmltReg = "<[^>]+>";
		/**
		 * 定义html页面中的匹配起
		 */
		Pattern script = Pattern.compile(scriptReg,Pattern.CASE_INSENSITIVE);
		textStr = script.matcher(htmlStr).replaceAll("");
		Pattern style =Pattern.compile(styleReg,Pattern.CASE_INSENSITIVE);
		textStr = style.matcher(textStr).replaceAll("");
		Pattern html =Pattern.compile(htmltReg,Pattern.CASE_INSENSITIVE);;
		textStr = html.matcher(textStr).replaceAll("");
		return textStr;
	}
	
}
